package com.heeexy.example.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.heeexy.example.dao.EmpDao;
import com.heeexy.example.service.EmpService;
import com.heeexy.example.util.CommonUtil;

@Service
public class EmpServiceImpl implements EmpService {
    @Autowired
    private EmpDao empDao;

	@Override
	public JSONObject addEmp(JSONObject jsonObject) {	
		empDao.insert(jsonObject);
        return CommonUtil.successJson();
	}

	@Override
	public JSONObject listEmp(JSONObject jsonObject) {
		 CommonUtil.fillPageParam(jsonObject);
	        int count = empDao.count(jsonObject);
	        List<JSONObject> list =  empDao.listEmp(jsonObject);
	        return CommonUtil.successPage(jsonObject, list, count);
	}

	@Override
	public JSONObject updateEmp(JSONObject jsonObject) {
		empDao.update(jsonObject);
        return CommonUtil.successJson();
	}
   //删除
	@Override
	public JSONObject deleteEmp(JSONObject jsonObject) {
		empDao.delete(jsonObject);
        return CommonUtil.successJson();
	}
	/**
	 * 查询所有的角色
	 * 在添加/修改用户的时候要使用此方法
	 */

@Override
public JSONObject getUser() {
	List<JSONObject> roles = empDao.getUser();
	return CommonUtil.successPage(roles);
}

	@Override
	public JSONObject listSal(JSONObject jsonObject) {
		CommonUtil.fillPageParam(jsonObject);
        int count = empDao.count(jsonObject);
        List<JSONObject> list =  empDao.getSal(jsonObject);
        return CommonUtil.successPage(jsonObject, list, count);
	}

	@Override
	public JSONObject listEname(JSONObject jsonObject) {
		CommonUtil.fillPageParam(jsonObject);
        int count = empDao.count(jsonObject);
        List<JSONObject> list =  empDao.getEname(jsonObject);
        return CommonUtil.successPage(jsonObject, list, count);
	}

	@Override
	public JSONObject listEage(JSONObject jsonObject) {
		CommonUtil.fillPageParam(jsonObject);
        int count = empDao.count(jsonObject);
        List<JSONObject> list =  empDao.getEage(jsonObject);
        return CommonUtil.successPage(jsonObject, list, count);
	}








}
